<template>
    <div>
        <h1>户型添加</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">姓名</td>
                    <td><input type="text"  v-model="info.Name"></td>
                </tr>
                <tr>
                    <td align="right">性别</td>
                    <td><input type="radio" name="sex" v-model="info.Sex" :value="true" >男
                        <input type="radio" name="sex" v-model="info.Sex" :value="false" >女
                    </td>
                </tr>
                <tr>
                    <td align="right">手机号</td>
                    <td><input type="text"  v-model="info.Phone"></td>
                </tr>
                <tr>
                    <td align="right">会员等级</td>
                    <td>
                        <select v-model="info.DJ">
                            <option value="">请选择</option>
                            <option value="普通会员">普通会员</option>
                            <option value="白银会员">白银会员</option>
                            <option value="黄金会员">黄金会员</option>
                            <option value="铂金会员">铂金会员</option>
                            <option value="钻石会员">钻石会员</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right">消费金额</td>
                    <td><input type="text"  v-model="info.Pric"></td>
                </tr>
                <tr>
                    <td align="right">消费次数</td>
                    <td><input type="text"  v-model="info.CS"></td>
                </tr>
                <tr>
                    <td align="right">可用积分</td>
                    <td><input type="text"  v-model="info.JiFen"></td>
                </tr>
                <tr>
                    <td align="right">可用余额</td>
                    <td><input type="text"  v-model="info.Money"></td>
                </tr>
                <tr>
                    <td align="right">启用状态</td>
                    <td><input type="radio" name="state" v-model="info.State" :value="true" >开启
                        <input type="radio" name="state" v-model="info.State" :value="false" >关闭</td>
                </tr>
                <tr>
                    <td align="right"></td>
                    <td><input type="button" value="录入" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive} from 'vue'
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter();
let info:any=reactive({
  Name: '',
  Sex: false,
  Phone: '',
  DJ: '',
  Pric: '',
  CS: '',
  JiFen: '',
  Money: '',
  State: true
})
const ok=()=>{
    if(info.Name=="")
{
    alert("姓名不能为空");
    return;
}
 if(info.Phone=="")
{
    alert("性别不能为空");
    return;
}

 if(info.DJ=="")
{
    alert("等级不能为空");
    return;
}
 if(info.Pric=="")
{
    alert("消费金额不能为空");
    return;
}
 if(info.CS=="")
{
    alert("消费次数不能为空");
    return;
}
 if(info.JiFen=="")
{
    alert("可用积分不能为空");
    return;
}
 if(info.JiFen<=0 || info.JiFen>1000)
{
    alert("积分不得低于0分不得高于1000分");
    return;
}
if(info.Money=="")
{
    alert("可用余额不能为空");
    return;
}
axios({
    url:'/api/Day/GetAdd',
    method:'post',
    data:info
})
.then((res)=>{
    console.log(res);
    if(res.data==-1)
{
    alert("姓名重复");
    return;
}
if(res.data>0)
{
    alert("录入成功");
    return;
}
else
{
    alert("录入失败");
    return;
}
})
.catch((err)=>{
    console.log(err);
})
}
</script>

<style scoped>

</style>